package com.lemt.user.controller;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.lemt.user.entity.Meau;
import com.lemt.user.service.IMeauService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author zik
 * @since 2023-09-10
 */
@Api(tags = "权限管理")
@RestController
@RequestMapping("/meau")
public class MeauController {
    @Resource(name = "IMeauService")
    private IMeauService meauService;


    @ApiOperation(value = "添加权限")
    @ApiOperationSupport(order=1 , includeParameters = {"meau.meauName","meau.meauUrl"})
    @PostMapping("/saveMeau")
    public Boolean addMeau(@RequestBody Meau meau){
        return meauService.save(meau);
    }

    @ApiOperation(value = "删除权限")
    @ApiOperationSupport(order=1 , includeParameters = {"meau.id"})
    @DeleteMapping("/removeMeauById")
    public Boolean remove(@RequestBody Meau meau) {
        return meauService.removeById(meau);
    }

    @ApiOperation(value = "修改权限")
    @ApiOperationSupport(ignoreParameters={"meau.createTime"})
    @PostMapping("/updateById")
    public Boolean update(@RequestBody Meau meau){
        return  meauService.updateById(meau);
    }

    @ApiOperation(value = "获取全部权限")
    @GetMapping("/list")
    public List<Meau> list() {
        return meauService.list();
    }
}
